package edu.spec.wechat.web.servlet;

import edu.spec.wechat.kit.WechatKit;
import edu.spec.wechat.web.BeanFactoryContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

/**
 * Created by MadFrog on 2016/10/17.
 */
public class InitServlet extends HttpServlet {

    private static WebApplicationContext wc;
    private static String realPath;

    @Override
    public void init(ServletConfig config) throws ServletException{
        super.init(config);
        //初始化web应用常量
        wc = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
        realPath = config.getServletContext().getRealPath("");
        BeanFactoryContext.setWc(wc);
        //初始化wechat常量
        WechatKit.setWechatContext();
    }



    public static String getRealPath(){
        return realPath;
    }

    public static WebApplicationContext getWc(){
        return wc;
    }
}
